package com.zw.yzk.kabu.data.repository;


import com.zw.yzk.kabu.data.network.ServiceGenerator;
import com.zw.yzk.kabu.data.network.entity.ExhibitionListEntity;
import com.zw.yzk.kabu.data.network.entity.SearchExhibitionEntity;
import com.zw.yzk.kabu.data.network.service.SearchExhibitionService;
import com.zw.yzk.kabu.data.network.task.SearchExhibitionTask;
import com.zw.yzk.kabu.data.network.task.Task;

import javax.inject.Inject;

import rx.Observable;
import rx.functions.Func1;

/**
 * Created by zhanwei on 2017/1/4.
 */

public class SearchExhibitionRepository extends CommonRepository {


    @Inject
    public SearchExhibitionRepository() {
    }

    @Override
    protected Observable connectServer(Task task) {
        SearchExhibitionService service = ServiceGenerator.createService(SearchExhibitionService.class);
        SearchExhibitionTask searchTask = (SearchExhibitionTask) task;
        return service.searchExhibition(searchTask.start, 10, searchTask.key);
    }

    @Override
    protected Func1<SearchExhibitionEntity, Observable> getServerData() {
        return new Func1<SearchExhibitionEntity, Observable>() {
            @Override
            public Observable call(SearchExhibitionEntity entity) {
                return Observable.just(entity);
            }
        };
    }

}
